<HTML><HEAD><TITLE>schedule_suspensions(+Position, +Attribute)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Advanced Control and Suspensions</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>schedule_suspensions(+Position, +Attribute)</H1>
Take the suspension list on argument position Position within Attribute,
and schedule them for execution.


<DL>
<DT><EM>Position</EM></DT>
<DD>Integer indicating the position of the suspension list.
</DD>
<DT><EM>Attribute</EM></DT>
<DD>Compound term, typically a variable's attribute                 with a suspension list in Position'th argument.
</DD>
</DL>
<H2>Description</H2>
   Suspensions in ECLiPSe go through several stages: They are created,
   attached to variables or symbolic triggers, later scheduled for execution,
   and finally executed.

<P>
   The task of schedule_suspensions/2 is to take suspensions
   from a suspension list and schedule them for execution.
   The suspensions are put into a global priority list, according
   to their individual priority. A subsequent wake/0 will then
   actually execute them.

<P>
   As a side effect, the suspension list within Attribute is updated,
   ie. suspensions which are no longer useful are removed destructively.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>schedule_suspensions(+, +) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Position or Attribute is not instatiated.
<DT><EM>(5) type error </EM>
<DD>Position is not an integer.
<DT><EM>(5) type error </EM>
<DD>Attribute is not a structure or it Position'th argument                is not a list of suspensions.
<DT><EM>(6) out of range </EM>
<DD>Attribute does not have a Position'th argument.
</DL>
<H2>Examples</H2>
<PRE>
[eclipse 1]: make_suspension(writeln(hello), 4, S),
             make_suspension(writeln('hi there'), 2, T),
	     Attr = attr([S,T]),
             schedule_suspensions(1, Attr),
             wake.
hi there
hello

S = 'SUSP-_306-dead'
T = 'SUSP-_311-dead'
Attr = attr([])
yes.

[eclipse 2]: [user].
 :- demon(d/0).
 d :- writeln(demon).

user       compiled traceable 68 bytes in 0.12 seconds

yes.
[eclipse 3]: make_suspension(d, 4, S), 
             make_suspension(writeln('hi there'), 2, T),
	     Attr = attr([S,T]),
	     schedule_suspensions(1,Attr),
	     wake.
hi there
demon

S = 'SUSP-_304-susp'
T = 'SUSP-_309-dead'
Attr = attr(['SUSP-_304-susp'])

Delayed goals:
        d
yes.
</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/compiler/demon-1.html">demon / 1</A>, <A HREF="../../kernel/suspensions/insert_suspension-3.html">insert_suspension / 3</A>, <A HREF="../../kernel/suspensions/insert_suspension-4.html">insert_suspension / 4</A>, <A HREF="../../kernel/suspensions/make_suspension-3.html">make_suspension / 3</A>, <A HREF="../../kernel/suspensions/get_suspension_data-3.html">get_suspension_data / 3</A>, <A HREF="../../kernel/suspensions/wake-0.html">wake / 0</A>
</BODY></HTML>
